package com.xiaotu.dao.sw;

import com.xiaotu.vo.*;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;
import java.util.Map;


/**
 * @author zhangxiao
 * @create 2021-08-26 10:59
 */
public interface SwMapper {

    /**
     * 根据艺人id 获取编剧是否审核通过
     *
     * @param starId
     * @return
     */
    Boolean getSwIsAuthSuccess(Integer starId);

    /**
     * 获取艺人信息
     *
     * @param starId
     * @return
     */
    SwInfoVo getSwInfoByStarId(Integer starId);

    /**
     * 获取艺人获奖信息
     *
     * @param starId
     * @return
     */
    List<ActorAwardVo> getActorAwards(Integer starId);

    /**
     * 参与作品
     *
     * @param starId
     * @return
     */
    List<PartiWorksVo> getPartiWorks(Integer starId);

    /**
     * 参与作品
     *
     * @param starId
     * @param tvType
     * @return
     */
    List<PartiWorksInfoVo> getPartiWorksInfo(@Param("starId") Integer starId, @Param("tvType") Integer tvType);

    /**
     * 合作艺人
     *
     * @param starId
     * @return
     */
    List<CoActorVo> getCoActors(Integer starId);

    /**
     * 合作艺人
     *
     * @param occu   1：合作导演 2：合作演员 3：合作编剧
     * @param starId
     * @return
     */
    List<CoActorInfoVo> getCoActorInfos(@Param("occu") Integer occu, @Param("starId") Integer starId);

    @Select("<script>" +
            " SELECT " +
            " t1.fansCount, " +
            " t2.commentCount,  " +
            " t3.viewCount  " +
            "FROM " +
            " ( SELECT COUNT( 1 ) fansCount FROM tab_sw_concern WHERE be_concern_star_id = #{starId} AND concern_status = 1 ) t1, " +
            " ( SELECT COUNT( 1 ) commentCount FROM tab_sw_comment WHERE be_comment_star_id = #{starId} AND auth_status = 1 ) t2, " +
            " ( SELECT COUNT( 1 ) viewCount FROM tab_sw_views WHERE starid = #{starId} ) t3 " +
            "</script>")
    Map<String, Object> getFansCommentsCount(Integer starId);

    @Select({"<script>" +
            " SELECT  " +
            "  t2.auth_type AS authType   " +
            "FROM  " +
            "  tab_sw_user t1  " +
            "  INNER JOIN tab_sw_auth_info t2 ON t1.userid = t2.userid   " +
            "WHERE  " +
            "  t1.starid = #{starId} " +
            "</script>"})
    Integer getAuthType(Integer starId);
}
